FROM php:8.0-fpm

# 更换为官方 Debian 镜像源
RUN sed -i 's|http://mirrors.aliyun.com|http://deb.debian.org|g' /etc/apt/sources.list

# RUN apt-get clean

#编译安装核心扩展
RUN apt-get update &&\
    apt-get install -y     libfreetype6-dev libjpeg62-turbo-dev libpng-dev zip &&\
    docker-php-ext-configure gd --with-freetype --with-jpeg &&\
    docker-php-ext-install -j$(nproc) gd pdo_mysql bcmath fileinfo pcntl

# 安装 swoole 扩展
RUN pecl install swoole \
    && docker-php-ext-enable swoole

# 安装 Redis 扩展
RUN pecl install redis \
    && docker-php-ext-enable redis

# 安装 Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# 设置工作目录
WORKDIR /var/www

# 拷贝项目文件
COPY . /var/www

# 运行 Composer install 并安装 think-swoole
#RUN composer install --prefer-dist
#RUN composer require topthink/think-swoole

# 设置 PHP-FPM 的监听端口
EXPOSE 9000

# 启动 PHP-FPM
CMD ["php-fpm"]
